package com.ruoyi.slope.video.AICamera.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.slope.dataFile.domain.SlopeDataFile;
import com.ruoyi.slope.dataFile.service.ISlopeDataFileService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.slope.video.AICamera.domain.SlopeCameraAi;
import com.ruoyi.slope.video.AICamera.service.ISlopeCameraAiService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 边坡落石及碎落监测Controller
 * 
 * @author ruoyi
 * @date 2025-05-11
 */
@RestController
@RequestMapping("/video/AICamera")
public class SlopeCameraAiController extends BaseController
{    
    @Autowired
    private ISlopeDataFileService slopeDataFileService;
    @Autowired
    private ISlopeCameraAiService slopeCameraAiService;

    /**
     * 查询边坡落石及碎落监测列表
     */
    @PreAuthorize("@ss.hasPermi('video:AICamera:list')")
    @GetMapping("/list")
    public TableDataInfo list(SlopeCameraAi slopeCameraAi)
    {
        startPage();
        List<SlopeCameraAi> list = slopeCameraAiService.selectSlopeCameraAiList(slopeCameraAi);
        return getDataTable(list);
    }

    /**
     * 导出边坡落石及碎落监测列表
     */
    @PreAuthorize("@ss.hasPermi('video:AICamera:export')")
    @Log(title = "边坡落石及碎落监测", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SlopeCameraAi slopeCameraAi)
    {
        List<SlopeCameraAi> list = slopeCameraAiService.selectSlopeCameraAiList(slopeCameraAi);
        ExcelUtil<SlopeCameraAi> util = new ExcelUtil<SlopeCameraAi>(SlopeCameraAi.class);
        String path = util.exportExcel(response, list, "边坡落石及碎落监测数据"); 
        SlopeDataFile slopeDataFile = new SlopeDataFile();
        slopeDataFile.setFileName(path);
        slopeDataFileService.insertSlopeDataFile(slopeDataFile);
    }

    /**
     * 获取边坡落石及碎落监测详细信息
     */
    @PreAuthorize("@ss.hasPermi('video:AICamera:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(slopeCameraAiService.selectSlopeCameraAiById(id));
    }

    /**
     * 新增边坡落石及碎落监测
     */
    @PreAuthorize("@ss.hasPermi('video:AICamera:add')")
    @Log(title = "边坡落石及碎落监测", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SlopeCameraAi slopeCameraAi)
    {
        return toAjax(slopeCameraAiService.insertSlopeCameraAi(slopeCameraAi));
    }

    /**
     * 修改边坡落石及碎落监测
     */
    @PreAuthorize("@ss.hasPermi('video:AICamera:edit')")
    @Log(title = "边坡落石及碎落监测", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SlopeCameraAi slopeCameraAi)
    {
        return toAjax(slopeCameraAiService.updateSlopeCameraAi(slopeCameraAi));
    }

    /**
     * 删除边坡落石及碎落监测
     */
    @PreAuthorize("@ss.hasPermi('video:AICamera:remove')")
    @Log(title = "边坡落石及碎落监测", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(slopeCameraAiService.deleteSlopeCameraAiByIds(ids));
    }
}
